import Vue from 'vue'
import App from './App.vue'
import router from './router/index.js'
import store  from './store'
import './assets/css/reset.css' //引入全局样式
import 'animate.css'

//引入ElementUI
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// 引入vant
import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);

Vue.config.productionTip = false

// 尝试从本地存储提取用户信息，并初始化状态机
let uinfo = localStorage.getItem('userInfo')
if(uinfo){
  let userinfo = JSON.parse(uinfo)
  store.commit('my/initInfoMut',userinfo)
  let {_id} = userinfo //提取登录了的用户id
  store.dispatch('cart/initCartAct',_id)
}



new Vue({
  router, //注入路由
  store, //注入状态机
  render: h => h(App),
}).$mount('#app')
